<extend name="_layout/main" />
<block name="content">
     <div class="login-container animated fadeInDown">
        <div class="loginbox bg-white">
        	<form id="loginForm" method="post">
            <div class="loginbox-title">Login</div>
            <div class="loginbox-social">
                <div class="social-title "></div>
                
            </div>
           
            <div class="loginbox-textbox">
                <input type="text" class="form-control" name="username" id="username" placeholder="登录名" />
            </div>
            <div class="loginbox-textbox">
                <input type="password" class="form-control" name="password" id="password" placeholder="密码" />
            </div>
             <div class="loginbox-textbox clearfix">
                <input type="text" class="form-control" name="verify" id="verify" placeholder="验证码" style="width: 100px; float: left; border-radius: 5px;" />
                <img title="点击刷新验证码" src="{:U('Captcha/show')}" style="width: 110px; height: 34px; float: right;" onclick="this.src='{:U(\'Captcha/show\')}'+'#'+Math.random()">
            </div>
            
            <div class="loginbox-submit">
                <input type="submit" class="btn btn-primary btn-block" value="登陆">
            </div>
            </form>
        </div>
       
    </div>

</block>

<block name="footer">
<script src="/Public/assets/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
	
	<script type="text/javascript">
		if(window.top != window.self){ 
			window.top.location.href = location.href;
		}
		$("#loginForm").submit(function(e){
			e.preventDefault();
			var username = $("#username").val();
			var password = $("#password").val();
			var verify = $("#verify").val();
			if(!username){
				bootbox.alert("<h4 class='danger'>登录名不能为空</h4>");
				return false;
			}
			if(!password){
				bootbox.alert("<h4 class='danger'>登陆密码不能为空</h4>");
				return false;
			}
			if(!verify){
				bootbox.alert("<h4 class='danger'>验证码不能为空</h4>");
				return false;
			}
			$("#loginForm").ajaxSubmit(function(result){
				result = JSON.parse(result);
				if(result.status == 'success'){ 
					location.href = '{:U('index/index')}';
				}else{ 
					bootbox.alert("<h4 class='danger'>"+result.message+"</h4>");
					if(result.hasOwnProperty('code') && parseInt(result.code) == 99){ 
						$("#verify").val('').siblings("img").trigger("click");
					}
					return false;
				}
			});
		})
	</script>
</block>
